//
//  CompressionController.h
//  VidCrusher
//
//  Created by Cemil Browne on 5/06/08.
//  Copyright 2008 Cemil Browne. All rights reserved.
//
/*
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */ 

#import <Cocoa/Cocoa.h>
#import <QuickTime/QuickTime.h>
#import <QTKit/QTKit.h>
#import "VideoItem.h"
#import "UKDockProgressIndicator.h"


int shouldStop;

@interface CompressionController : NSObject {
	// Interface Builder outlet
	IBOutlet NSArrayController* myArrayController;
	IBOutlet NSPopUpButton *compressFor;
	IBOutlet NSTextField* destinationPath;
	IBOutlet NSTextField* height;
	IBOutlet NSTextField* width;
	IBOutlet NSTextField* bitrate;
	IBOutlet NSButton* addToItunes;
	IBOutlet NSButton* deleteAfterAdding;
	IBOutlet NSProgressIndicator* overallProgressIndicator;
	IBOutlet NSProgressIndicator* fileProgressIndicator;
	IBOutlet NSTextField* overallProgressLabel;
	IBOutlet NSTextField* fileProgressLabel;
	IBOutlet NSWindow* compressionSheet;
	UKDockProgressIndicator* dockProgressIndicator;
	// End of outlets. 
	
	// private variables.  
	NSArray *componentList;
	NSEnumerator *arrangedObjectEnumerator;
	int curIndex;
	int total;
	NSString *_curTag;
	NSString *_curOverallTag;
}


- (void) beginCompressing; // Called from AppController to begin the compression. 
- (NSArray *)availableComponents; // Helper function to find availableComponents
- (BOOL)writeMovie:(QTMovie *)movie toFile:(NSString *)file withComponent:(NSDictionary *)component withExportSettings:(NSData *)exportSettings withVideoItem:(VideoItem *)aVideoItem; // all info is passed here, then passed to doThreadedWrite
- (int) findComponent:(NSString *)name; // Finds a quicktime component by name from availablecomponents
- (void) doThreadedWrite:(NSArray *) args; // Called in a NSThread to do the writing. 
- (void) performNextExport:(id) anObject; // This is the main loop to get the next item + write it. 
- (void) updateOverAllProgressBar: (NSNumber *)percent; // Back call from video writing thread to update the overall progress bar. 
- (void)importMusicFile:(NSString*)inPath; // add a music file to itunes
- (void) checkForiTunes; // Check whether iTunes is running. 

@end
